#include "IRutils.h"
/// Sum all the bytes of an array and return the least significant 8-bits of
/// the result.
/// @param[in] start A ptr to the start of the byte array to calculate over.
/// @param[in] length How many bytes to use in the calculation.
/// @param[in] init Starting value of the calculation to use. (Default is 0)
/// @return The 8-bit calculated result of all the bytes and init value.
uint8_t sumBytes(const uint8_t *const start, const uint16_t length,
                 const uint8_t init)
{
    uint8_t checksum = init;
    const uint8_t *ptr;
    for (ptr = start; ptr - start < length; ptr++)
        checksum += *ptr;
    return checksum;
}